#include <cv.h>
#include <highgui.h>
#include <stdio.h>
#include <vector>
#include <jpgd.h>
#include <jpge.h>
#include <profiler.h>
#include <camera.h>
#include <mjpeg_streamer.h>
#include <socket.h>
#include <property_manager.h>
#include <font.h>
#include <colors.h>
#include <bp.h>
#include <appcommon.h>
#include <multithreading.h>
#include <stereoapp.h>

MJPEGClientI* clientFactory(char* appname, MJPEGStreamer* s)
{
	if(strcmp(appname, "stereo") == 0)
	{
		return new ClientStereoApp(s);
	}
	assert("Nie ma klienta!");
	return 0;
}

MJPEGServerI* serverFactory(char* appname, MJPEGStreamer* s)
{
	if(strcmp(appname, "stereo") == 0)
	{
		return new ServerStereoApp(s);
	}
	assert("Nie ma servera!");
	return 0;
}

int main(int argc, char** argv)
{
	Properties* appprop = AppSettings::instance()->properties;
	MJPEGStreamer mjpegstreamer;
	
	char* app2run = appprop->get("app_to_run");
			
	if(strcmp(argv[1],"server") == 0)
	{
		MJPEGServerI* server = serverFactory(app2run, &mjpegstreamer);
		mjpegstreamer.run_server(server);
	}
	else if(strcmp(argv[1],"client") == 0)
	{
		MJPEGClientI* client = clientFactory(app2run, &mjpegstreamer);
		mjpegstreamer.run_client(client);
	}
	
	return 0;
}